VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmMenuPad 
   BackColor       =   &H00800000&
   Caption         =   "frmMenuPad"
   ClientHeight    =   5115
   ClientLeft      =   2775
   ClientTop       =   1980
   ClientWidth     =   8220
   LinkTopic       =   "Form1"
   ScaleHeight     =   5115
   ScaleWidth      =   8220
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   4215
      Top             =   150
      Visible         =   0   'False
      Width           =   2475
      _ExtentX        =   4366
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "1.MenuPad"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataListLib.DataCombo cboMenuPad 
      Bindings        =   "frmMenuPad.frx":0000
      Height          =   360
      Left            =   2325
      TabIndex        =   17
      Top             =   840
      Width           =   5220
      _ExtentX        =   9208
      _ExtentY        =   635
      _Version        =   393216
      ForeColor       =   8388608
      ListField       =   "PadNameIndex"
      BoundColumn     =   "Padcode"
      Text            =   ""
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.CommandButton cmdAddnew 
      Caption         =   "&New pad"
      Height          =   372
      Left            =   840
      TabIndex        =   16
      Top             =   4485
      Width           =   996
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit"
      Height          =   372
      Left            =   1920
      TabIndex        =   15
      Top             =   4485
      Width           =   948
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Height          =   372
      Left            =   2925
      TabIndex        =   14
      Top             =   4485
      Width           =   984
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   372
      Left            =   3990
      TabIndex        =   13
      Top             =   4485
      Width           =   1032
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   372
      Left            =   6105
      TabIndex        =   12
      Top             =   4485
      Width           =   1080
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "&Delete"
      Height          =   372
      Left            =   5085
      TabIndex        =   11
      Top             =   4485
      Width           =   960
   End
   Begin VB.Frame FramePadName 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   2685
      Left            =   585
      TabIndex        =   0
      Top             =   1500
      Width           =   7065
      Begin VB.TextBox txtPadcode 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800080&
         Height          =   360
         Left            =   1650
         TabIndex        =   21
         Top             =   45
         Width           =   1185
      End
      Begin VB.TextBox txtFullPadName 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800080&
         Height          =   360
         Left            =   1650
         TabIndex        =   10
         Top             =   2145
         Width           =   3630
      End
      Begin VB.TextBox txtParentPadcode 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800080&
         Height          =   360
         Left            =   1635
         TabIndex        =   9
         Top             =   825
         Width           =   1200
      End
      Begin VB.TextBox txtPadIndex 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800080&
         Height          =   360
         Left            =   1650
         TabIndex        =   8
         Top             =   1680
         Width           =   1200
      End
      Begin VB.TextBox txtPadName 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800080&
         Height          =   360
         Left            =   1650
         TabIndex        =   7
         Top             =   1275
         Width           =   1200
      End
      Begin VB.TextBox txtCaption 
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00800080&
         Height          =   360
         Left            =   1650
         TabIndex        =   6
         Top             =   420
         Width           =   3630
      End
      Begin MSDataListLib.DataCombo cboParentPadCode 
         Bindings        =   "frmMenuPad.frx":0015
         Height          =   360
         Left            =   2865
         TabIndex        =   20
         Top             =   840
         Width           =   3825
         _ExtentX        =   6747
         _ExtentY        =   635
         _Version        =   393216
         ForeColor       =   8388736
         ListField       =   "PadNameIndex"
         BoundColumn     =   "Padcode"
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Arial"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Pad code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   255
         Index           =   4
         Left            =   105
         TabIndex        =   22
         Top             =   120
         Width           =   990
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Parent pad code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   270
         Index           =   3
         Left            =   105
         TabIndex        =   19
         Top             =   900
         Width           =   1455
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Caption"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   2
         Left            =   105
         TabIndex        =   5
         Top             =   495
         Width           =   765
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Pad name"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   255
         Index           =   5
         Left            =   105
         TabIndex        =   4
         Top             =   1350
         Width           =   990
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Full pad name"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   13
         Left            =   105
         TabIndex        =   3
         Top             =   2190
         Width           =   1290
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Pad Index"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   255
         Index           =   7
         Left            =   105
         TabIndex        =   2
         Top             =   1770
         Width           =   1005
      End
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Select menu Pad"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0080FFFF&
      Height          =   225
      Index           =   0
      Left            =   570
      TabIndex        =   18
      Top             =   840
      Width           =   1575
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Input Menu Pad"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   495
      Index           =   1
      Left            =   225
      TabIndex        =   1
      Top             =   225
      Width           =   3270
   End
End
Attribute VB_Name = "frmMenuPad"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim OldPadcode As String
Private Sub cboMenuPad_Click(Area As Integer)
If Area = 2 Then
    txtPadcode = cboMenuPad.BoundText
    
    ISADDING = False
    ISEDITING = False
    WriteToScreen
    ' Ham Gan tri man hinh
    ButtonStatus

End If
End Sub

Private Sub cboParentPadCode_Click(Area As Integer)
If Area = 2 Then
    txtParentPadcode = cboParentPadCode.BoundText
    If txtParentPadcode = "" Then
        MsgBox "Note ! This is a Menu Bar."
        txtPadName = "mn"
        txtFullPadName = txtPadcode
    Else
            Dim strFull As String
            strFull = Find("MenuPad", "fullpadname", " WHERE Padcode='" & txtParentPadcode & "'")
            If strFull <> "" Then
                txtFullPadName = strFull & "_" & txtPadcode
            Else
                MsgBox "Not have this Pad code!"
                txtParentPadcode = ""
                cboParentPadCode.SetFocus
            End If
            txtPadName = txtParentPadcode
    End If
    txtPadIndex.SetFocus
End If
End Sub

Private Sub cmdAddnew_Click()
ISADDING = True
ISEDITING = True
WriteToScreen
' Ham Gan tri man hinh
ButtonStatus
txtPadcode.SetFocus
End Sub

Sub ButtonStatus()
cmdAddNew.Enabled = Not ISEDITING
cmdEdit.Enabled = Not ISEDITING
cmdSave.Enabled = ISEDITING ' And txtIMITN <> ""
cmdDelete.Enabled = Not ISEDITING 'And txtIMITN <> ""
cmdCancel.Enabled = ISEDITING
FramePadName.Enabled = ISEDITING
End Sub

Private Sub cmdCancel_Click()

WriteToScreen
ISADDING = False
ISEDITING = False
ButtonStatus
'txtCaption.SetFocus
End Sub

Private Sub cmdDelete_Click()
Response = MsgBox("Do you really to delte this MenuPad?", vbYesNo + vbCritical + vbDefaultButton2, "Chu y'")
If Response = vbYes Then DBconn.Execute "DELETE From MenuPad Where PadCode=" & txtPadcode
End Sub

Private Sub cmdEdit_Click()
ISEDITING = True
WriteToScreen
' Ham Gan tri man hinh
ButtonStatus
txtCaption.SetFocus
End Sub

Private Sub cmdExit_Click()
Unload frmMenuPad
End Sub

Private Sub cmdSave_Click()

WriteToFile
cmdAddNew.SetFocus
'txtCaption.SetFocus
End Sub

Private Sub Form_Load()
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 10
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select PadCode,PadCode+' - '+ Caption  as PadNameIndex from MenuPad order by padcode"
Adodc1.Refresh

ISADDING = False
ISEDITING = False
ButtonStatus
End Sub
Sub WriteToScreen()
Dim RecMenuPad As Recordset
If ISADDING Then
    txtPadcode = ""
    txtCaption = ""
    txtPadName = ""
    txtPadIndex = 0
    txtParentPadcode = ""
    
    txtFullPadName = ""
Else
        Set RecMenuPad = DBconn.Execute("Select * from MenuPad where PadCode='" & txtPadcode & "'")
        If Not RecMenuPad.EOF Then
            txtCaption = RecMenuPad!Caption
            txtPadName = RecMenuPad!PadName
            txtPadIndex = RecMenuPad!PadIndex
            txtParentPadcode = RecMenuPad!ParentPadCode
            
            txtFullPadName = RecMenuPad!FullPadName
        Else
            txtPadcode = ""
            txtCaption = ""
            txtPadName = ""
            txtPadIndex = 0
            txtParentPadcode = ""
            txtFullPadName = ""
        End If
End If
cboMenuPad.BoundText = txtPadcode
cboParentPadCode.BoundText = txtParentPadcode
OldPadcode = txtPadcode
End Sub
Sub WriteToFile()
Dim SQL
If txtPadcode = "" Then
    MsgBox "Invalid Pad code!"
    Exit Sub
End If
If ValidMaso(OldPadcode, txtPadcode, "MenuPad", " Padcode='" & txtPadcode & "'") Then
    MsgBox "Duplicate Pad code!"
    Exit Sub
End If

If ISADDING Then
    SQL = "Insert into Menupad(Padcode,PadName,PadIndex,ParentPadcode,FullPadName,Caption) values " & _
    "('" & txtPadcode & "','" & txtPadName & "'," & txtPadIndex & ",'" & txtParentPadcode & "'" & _
    ",'" & txtFullPadName & "','" & txtCaption & "')"
Else
    SQL = "Update MenuPad set  Padcode= '" & txtPadcode & "', Padname= '" & txtPadName & "',PadIndex=" & txtPadIndex & ",ParentPadCode='" & txtParentPadcode & "'" & _
    ",FullPadName='" & txtFullPadName & "',Caption='" & txtCaption & "'" & _
    " WHERE PadCode='" & txtPadcode & "'"
End If
DBconn.Execute SQL

Adodc1.RecordSource = "Select PadCode,PadCode+' - '+Caption   as PadNameIndex from MenuPad order by padcode"
Adodc1.Refresh
cboMenuPad.ReFill
cboMenuPad.Refresh
cboMenuPad.BoundText = txtPadcode
cboParentPadCode.ReFill
cboParentPadCode.Refresh

ISADDING = False
ISEDITING = False
ButtonStatus
End Sub



Private Sub txtCaption_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtParentPadcode.SetFocus

End Sub

Private Sub txtPadcode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If ValidMaso(OldPadcode, txtPadcode, "MenuPad", " Padcode='" & txtPadcode & "'") Then
        MsgBox "Duplicate Pad code!"
        txtPadcode.SetFocus
        Exit Sub
    End If
    txtCaption.SetFocus
End If
End Sub

Private Sub txtPadIndex_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then cmdSave.SetFocus
End Sub

Private Sub txtPadName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtPadIndex.SetFocus
End Sub

Private Sub txtParentIndex_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Dim strFull As String
    strFull = Find("MenuPad", "fullpadname", " WHERE Padname='" & txtParentName & "' and PadIndex=" & txtParentIndex)
    If strFull <> txtPadName Then
        txtFullPadName = strFull & "_" & txtPadName
    Else
        txtFullPadName = txtPadName
    End If
    cmdSave.SetFocus
End If
End Sub

Private Sub txtParentName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   
End If
End Sub

Private Sub txtParentPadcode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If txtParentPadcode = "" Then
        MsgBox "Note ! This is a Menu Bar."
        txtPadName = "mn"
        txtFullPadName = txtPadcode
    Else
            Dim strFull As String
            strFull = Find("MenuPad", "fullpadname", " WHERE Padcode='" & txtParentPadcode & "'")
            If strFull <> "" Then
                txtFullPadName = strFull & "_" & txtPadcode
            Else
                MsgBox "Not have this Pad code!"
                txtParentPadcode = ""
                cboParentPadCode.SetFocus
            End If
            txtPadName = txtParentPadcode
    End If
    txtPadIndex.SetFocus
End If
cboParentPadCode.BoundText = txtParentPadcode
End Sub
